﻿package phpas3{
	public function empty(variable:*) : Boolean {

	    var isEmpty:Boolean;

	    if (variable == null || variable == undefined) {
	        isEmpty = true;
	    }
	    else if (variable is String) {
	        var str:String = variable.replace(/^\s+|\s+$/g, '');
	        isEmpty = (str.replace(/\s+/g, ' ') == "" || variable == "" || variable == "0" || variable == "false");
	    }
	    else if (variable is Number || variable is int || variable is uint) {
	        isEmpty = (variable == 0);
	    }
	    else if (variable is Array) {
	        isEmpty = (variable.length == 0);
	    }
	    else if (variable is Boolean) {
	        isEmpty = (variable == false);
	    }

	    return isEmpty;

	}
}